home *** CD-ROM | disk | FTP | other *** search
- include layout.inc
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
-
- ASSUME CS:_TEXT
- ASSUME DS:_TEXT
-
- PUBLIC START
- extrn _romstart:near
-
- ; public __acrtused ;This value makes many of the
- ; __acrtused = 9876h ;library routines happy
- ; should have no library routines!
-
- ifdef UNDER_DOS
- ORG 100h
- else
- org 0
- endif
- START PROC NEAR
- ifdef REALLY_ROM
- dw 0aa55h ; rom signature
- db 08000h / 512 ; size
- endif
- ifdef ROM_CODE
- pop dx
- pop ax
- mov bx, 100h
- mov cx, 6bf0h
- mov ss,bx ; put stack at 100:6bf0 -> 7bf0
- mov sp,cx
-
- push ax ; push far return address
- push dx
-
- MOV DX,CS ;
- mov ds,dx ; going to move ds:si to es:di
-
- cld
- mov es,bx
- xor di,di ; clear dest
- mov si,OFFSET CGROUP:_start_of_data
- ; move _DATA segment
- mov cx, offset dgroup:_end_of_data
- rep movsb
- ; now clear _BSS segment
- mov cx, offset dgroup:_end_of_bss
- sub cx, offset dgroup:_end_of_data
- mov al,0
- rep stosb
-
- mov ax,100h
- mov es,ax
- mov ds,ax
- STI ;Enable interrupts and the jump
- call _romstart ;to the start of the C code
-
- else
- MOV DX,CS ;
- mov ax,9800h ; nice high place
- mov es,ax
- cld
- xor di,di ; clear dest
- xor si,si
- mov cx, offset dgroup:_end_of_data
- rep movsb
- ; now clear _BSS segment
- mov cx, offset dgroup:_end_of_bss
- sub cx, offset dgroup:_end_of_data
- mov al,0
- rep stosb
-
- cli
- mov ax,9800h ; nice high place
- mov ds,ax
- mov es,ax
- mov ss,ax
- mov sp, 07ffeh ; stack
- ; I'm tired and I can't be bothered fighting this assembler
- db 0eah ; far jump
- dw offset dgroup: here_i_am
- dw 09800h
- here_i_am:
- STI ;Enable interrupts and the jump
- call _romstart ;to the start of the C code
- endif
-
- ifdef UNDER_DOS
- int 19h
- endif
- retf
- START ENDP
-
- _TEXT ENDS
-
- END START
-
-